#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include "coherentElastic/coherentElastic.h"
#include "generalTools/testing.h"


template <typename Range>
void checkAddedEnergies( const Range& finalE, const Range& eGrid, const Range& addedE ){
  bool in_eGrid, in_addedE;
  for ( const auto& E : finalE ){
    in_eGrid  = false;
    in_addedE = false;
    for ( const auto& eGridVal : eGrid ){
      if (E == Approx(eGridVal ).epsilon(1e-6)){ in_eGrid  = true; break; }
    }
    for ( const auto& addedEVal : addedE ){
      if (E == Approx(addedEVal).epsilon(1e-6)){ in_addedE = true; break; }
    }
      REQUIRE( (in_eGrid == true  or in_addedE == true)  );
      REQUIRE( (in_eGrid == false or in_addedE == false) );
  }
}




TEST_CASE( "coherent elastic - generate Bragg from scratch" ){
  std::vector<double> eGrid;
  eGrid = { 1E-5, 1.0625E-5, 1.125E-5, 1.1875E-5, 1.25E-5, 1.375E-5, 1.5E-5, 
  1.625E-5, 1.75E-5, 1.875E-5, 2E-5, 2.1875E-5, 2.375E-5, 2.5625E-5, 2.75E-5, 
  2.9375E-5, 3.125E-5, 3.3125E-5, 3.5E-5, 3.875E-5, 4.25E-5, 4.625E-5, 5E-5, 
  5.3125E-5, 5.625E-5, 5.9375E-5, 6.25E-5, 6.875E-5, 7.5E-5, 8.125E-5, 8.75E-5, 
  9.375E-5, 1E-4, 1.0625E-4, 1.125E-4, 1.1875E-4, 1.25E-4, 1.375E-4, 1.5E-4, 
  1.625E-4, 1.75E-4, 1.875E-4, 2E-4, 2.1875E-4, 2.375E-4, 2.5625E-4, 2.75E-4, 
  2.9375E-4, 3.125E-4, 3.3125E-4, 3.5E-4, 3.875E-4, 4.25E-4, 4.625E-4, 5E-4, 
  5.3125E-4, 5.625E-4, 5.9375E-4, 6.25E-4, 6.875E-4, 7.5E-4, 8.125E-4, 8.75E-4, 
  9.375E-4, 1E-3, 1.0625E-3, 1.125E-3, 1.1875E-3, 1.25E-3, 1.375E-3, 1.5E-3, 
  1.625E-3, 1.75E-3, 1.875E-3, 2E-3, 2.1875E-3, 2.375E-3, 2.5625E-3, 2.75E-3, 
  2.9375E-3, 3.125E-3, 3.3125E-3, 3.5E-3, 3.875E-3, 4.25E-3, 4.625E-3, 5E-3, 
  5.3125E-3, 5.625E-3, 5.9375E-3, 6.25E-3, 6.875E-3, 7.5E-3, 8.125E-3, 8.75E-3, 
  9.375E-3, 1E-2, 1.0625E-2, 1.125E-2, 1.1875E-2, 1.25E-2, 1.375E-2, 1.5E-2, 
  1.625E-2, 1.75E-2, 1.875E-2, 2E-2, 2.1325E-2, 2.265E-2, 2.3975E-2, 2.53E-2, 
  2.684375E-2, 2.83875E-2, 3.1475E-2, 3.45625E-2, 3.765E-2, 4.07375E-2,4.3825E-2, 
  4.69125E-2, 5E-2, 5.3125E-2, 5.625E-2, 5.9375E-2, 6.25E-2, 6.875E-2, 7.5E-2, 
  8.125E-2, 8.75E-2, 9.375E-2, 1E-1, 1.0625E-1, 1.125E-1, 1.1875E-1, 1.25E-1, 
  1.375E-1, 1.5E-1, 1.625E-1, 1.75E-1, 1.875E-1, 2E-1, 2.1875E-1, 2.375E-1, 
  2.5625E-1, 2.75E-1, 2.9375E-1, 3.125E-1, 3.3125E-1, 3.5E-1, 3.875E-1, 4.25E-1, 
  5.E-1, 6.25E-1, 7.5E-1, 8.75E-1, 1, 1.25, 1.5, 1.75, 2, 2.375, 2.75, 3.125, 
  3.5, 4.25, 5, 6.25, 7.5, 8.75, 10, 12.5, 15, 17.5, 20, 23.75, 27.5, 31.25, 35, 
  42.5, 50, 62.5, 75, 87.5, 100, 125, 150, 175, 200, 237.5, 275, 312.5, 350, 
  425, 500, 625, 750, 875, 1E3, 1.25E3, 1.5E3, 1.75E3, 2.E3, 2.25E3, 2.5E3, 
  2.75E3, 3.E3, 3.25E3, 3.5E3, 4.E3, 4.5E3, 5.E3, 5.5E3, 6.E3, 6.5E3, 7.E3, 
  8.E3, 9.E3, 1.E4, 1.125E4, 1.25E4, 1.5E4, 1.75E4, 2.E4, 2.25E4, 2.5E4, 2.75E4, 
  3.E4, 3.25E4, 3.5E4, 4.E4, 4.5E4, 5.E4, 5.5E4, 6.E4, 6.5E4, 7.E4, 7.5E4, 8.E4, 
  8.5E4, 9.E4, 9.5E4, 1.E5, 1.1E5, 1.2E5, 1.3E5, 1.4E5, 1.5E5, 1.6E5, 1.7E5, 
  1.8E5, 1.9E5, 2.E5, 2.2E5, 2.4E5, 2.6E5, 2.8E5, 3.E5, 3.2E5, 3.4E5, 3.6E5, 
  3.8E5, 4.E5, 4.2E5, 4.4E5, 4.6E5, 4.8E5, 5.E5, 5.5E5, 6.E5, 6.5E5, 7.E5, 7.5E5, 
  8.E5, 8.5E5, 9.E5, 9.5E5, 1.E6, 1.1E6, 1.2E6, 1.3E6, 1.4E6, 1.5E6, 1.6E6, 
  1.7E6, 1.8E6, 1.9E6, 2.E6, 2.2E6, 2.4E6, 2.6E6, 2.8E6, 3.E6, 3.2E6, 3.4E6, 
  3.6E6, 3.8E6, 4.E6, 4.2E6, 4.4E6, 4.6E6, 4.8E6, 5.E6, 5.2E6, 5.4E6, 5.6E6, 
  5.8E6, 6.E6, 6.2E6, 6.4E6, 6.6E6, 6.8E6, 7.E6, 7.5E6, 8.E6, 8.5E6, 9.E6, 9.5E6, 
  1.E7, 1.05E7, 1.1E7, 1.15E7, 1.2E7, 1.25E7, 1.3E7, 1.35E7, 1.4E7, 1.45E7, 
  1.5E7, 1.55E7, 1.6E7, 1.65E7, 1.7E7, 1.75E7, 1.8E7, 1.85E7, 1.9E7, 1.95E7, 2.E7};

  std::cout.precision(15);
  GIVEN( "material is graphite (lat = 1)" ){
    WHEN( "Room temperature, loose tolerance, low ish max energy" ){
      double temp = 296.0, emax = 0.625;
      int lat = 1, numAtoms = 1;
      double tol = 5e-2;
     
      std::vector<double> correct_finalE { 1.000000E-5, 1.062500E-5, 1.125000E-5, 
      1.187500E-5, 1.250000E-5, 1.375000E-5, 1.500000E-5, 1.625000E-5, 1.750000E-5, 
      1.875000E-5, 2.000000E-5, 2.187500E-5, 2.375000E-5, 2.562500E-5, 2.750000E-5, 
      2.937500E-5, 3.125000E-5, 3.312500E-5, 3.500000E-5, 3.875000E-5, 4.250000E-5, 
      4.625000E-5, 5.000000E-5, 5.312500E-5, 5.625000E-5, 5.937500E-5, 6.250000E-5, 
      6.875000E-5, 7.500000E-5, 8.125000E-5, 8.750000E-5, 9.375000E-5, 1.000000E-4, 
      1.062500E-4, 1.125000E-4, 1.187500E-4, 1.250000E-4, 1.375000E-4, 1.500000E-4, 
      1.625000E-4, 1.750000E-4, 1.875000E-4, 2.000000E-4, 2.187500E-4, 2.375000E-4, 
      2.562500E-4, 2.750000E-4, 2.937500E-4, 3.125000E-4, 3.312500E-4, 3.500000E-4, 
      3.875000E-4, 4.250000E-4, 4.555814E-4, 4.555816E-4, 4.625000E-4, 5.000000E-4, 
      5.312500E-4, 5.625000E-4, 5.937500E-4, 6.250000E-4, 6.875000E-4, 7.500000E-4, 
      8.125000E-4, 8.750000E-4, 9.375000E-4, 1.000000E-3, 1.062500E-3, 1.125000E-3, 
      1.187500E-3, 1.250000E-3, 1.375000E-3, 1.500000E-3, 1.625000E-3, 1.750000E-3, 
      1.822325E-3, 1.822327E-3, 1.875000E-3, 2.000000E-3, 2.187500E-3, 2.375000E-3, 
      2.562500E-3, 2.750000E-3, 2.937500E-3, 3.125000E-3, 3.312500E-3, 3.500000E-3, 
      3.875000E-3, 4.100232E-3, 4.100234E-3, 4.250000E-3, 4.515834E-3, 4.515836E-3, 
      4.625000E-3, 4.971415E-3, 4.971417E-3, 5.000000E-3, 5.312500E-3, 5.625000E-3, 
      5.937500E-3, 6.250000E-3, 6.338160E-3, 6.338162E-3, 6.875000E-3, 7.289303E-3, 
      7.289305E-3, 7.500000E-3, 8.125000E-3, 8.616067E-3, 8.616069E-3, 8.750000E-3, 
      9.375000E-3, 1.000000E-2, 1.062500E-2, 1.125000E-2, 1.138953E-2, 1.138955E-2, 
      1.180513E-2, 1.180515E-2, 1.187500E-2, 1.250000E-2, 1.354749E-2, 1.354751E-2, 
      1.375000E-2, 1.400308E-2, 1.400310E-2, 1.500000E-2, 1.536982E-2, 1.536984E-2, 
      1.590536E-2, 1.590538E-2, 1.625000E-2, 1.640092E-2, 1.640094E-2, 1.750000E-2, 
      1.764773E-2, 1.764775E-2, 1.806333E-2, 1.806335E-2, 1.851891E-2, 1.851893E-2, 
      1.875000E-2, 1.988565E-2, 1.988567E-2, 2.000000E-2, 2.083680E-2, 2.083682E-2, 
      2.091676E-2, 2.091678E-2, 2.132500E-2, 2.216356E-2, 2.216358E-2, 2.232348E-2, 
      2.232350E-2, 2.265000E-2, 2.397500E-2, 2.493703E-2, 2.493705E-2, 2.530000E-2, 
      2.535263E-2, 2.535265E-2, 2.683932E-2, 2.683934E-2, 2.684375E-2, 2.838750E-2, 
      2.915720E-2, 2.915722E-2, 2.945287E-2, 2.945289E-2, 2.994843E-2, 2.994845E-2, 
      3.147500E-2, 3.161083E-2, 3.161085E-2, 3.206641E-2, 3.206643E-2, 3.343316E-2, 
      3.343318E-2, 3.367304E-2, 3.367306E-2, 3.446426E-2, 3.446428E-2, 3.456250E-2, 
      3.571107E-2, 3.571109E-2, 3.587099E-2, 3.587101E-2, 3.690209E-2, 3.690211E-2, 
      3.765000E-2, 3.890014E-2, 3.890016E-2, 4.038682E-2, 4.038684E-2, 4.064250E-2, 
      4.064252E-2, 4.073750E-2, 4.109808E-2, 4.109810E-2, 4.141792E-2, 4.141794E-2, 
      4.246483E-2, 4.246485E-2, 4.270471E-2, 4.270473E-2, 4.300037E-2, 4.300039E-2, 
      4.382500E-2, 4.474274E-2, 4.474276E-2, 4.555814E-2, 4.555816E-2, 4.691250E-2, 
      4.722054E-2, 4.722056E-2, 4.793181E-2, 4.793183E-2, 4.801177E-2, 4.801179E-2, 
      5.000000E-2, 5.007397E-2, 5.007399E-2, 5.312500E-2, 5.393433E-2, 5.393435E-2, 
      5.496543E-2, 5.496545E-2, 5.512535E-2, 5.512537E-2, 5.625000E-2, 5.829024E-2, 
      5.829026E-2, 5.870584E-2, 5.870586E-2, 5.910564E-2, 5.910566E-2, 5.937500E-2, 
      5.964118E-2, 5.964120E-2, 6.250000E-2, 6.280607E-2, 6.280609E-2, 6.296599E-2, 
      6.296601E-2, 6.362148E-2, 6.362150E-2, 6.560372E-2, 6.560374E-2, 6.875000E-2, 
      6.979972E-2, 6.979974E-2, 7.011956E-2, 7.011958E-2, 7.407567E-2, 7.407569E-2, 
      7.500000E-2, 7.699326E-2, 7.699328E-2, 8.102933E-2, 8.102935E-2, 8.125000E-2, 
      8.150909E-2, 8.150911E-2, 8.580085E-2, 8.580087E-2, 8.620065E-2, 8.620067E-2, 
      8.750000E-2, 8.929396E-2, 8.929398E-2, 9.375000E-2, 9.380979E-2, 9.380981E-2, 
      9.893275E-2, 9.893277E-2, 1.000000E-1, 1.014105E-1, 1.014107E-1, 1.025057E-1, 
      1.025059E-1, 1.062500E-1, 1.081243E-1, 1.081245E-1, 1.086040E-1, 1.086042E-1, 
      1.091554E-1, 1.091556E-1, 1.125000E-1, 1.147181E-1, 1.147183E-1, 1.166288E-1, 
      1.166290E-1, 1.187500E-1, 1.227029E-1, 1.227031E-1, 1.239896E-1, 1.239898E-1, 
      1.242853E-1, 1.242855E-1, 1.250000E-1, 1.273786E-1, 1.273788E-1, 1.299364E-1, 
      1.299366E-1, 1.316629E-1, 1.316631E-1, 1.375000E-1, 1.383284E-1, 1.383286E-1, 
      1.399908E-1, 1.399910E-1, 1.403906E-1, 1.403908E-1, 1.420530E-1, 1.420532E-1, 
      1.431482E-1, 1.431484E-1, 1.476083E-1, 1.476085E-1, 1.500000E-1, 1.556005E-1, 
      1.556007E-1, 1.563917E-1, 1.563919E-1, 1.572713E-1, 1.572715E-1, 1.625000E-1, 
      1.644648E-1, 1.644650E-1, 1.739595E-1, 1.739597E-1, 1.747591E-1, 1.747593E-1, 
      1.750000E-1, 1.822325E-1, 1.822327E-1, 1.875000E-1, 1.917272E-1, 1.917274E-1, 
      2.000000E-1, 2.002958E-1, 2.002960E-1, 2.009113E-1, 2.009115E-1, 2.112214E-1, 
      2.112216E-1, 2.114613E-1, 2.114615E-1, 2.138433E-1, 2.138435E-1, 2.144588E-1, 
      2.144590E-1, 2.154016E-1, 2.154018E-1, 2.187500E-1, 2.189747E-1, 2.189749E-1, 
      2.205013E-1, 2.205015E-1, 2.325222E-1, 2.325224E-1, 2.326653E-1, 2.326655E-1, 
      2.367182E-1, 2.367184E-1, 2.375000E-1, 2.385647E-1, 2.385649E-1, 2.410025E-1, 
      2.410027E-1, 2.531107E-1, 2.531109E-1, 2.544858E-1, 2.544860E-1, 2.562500E-1, 
      2.590658E-1, 2.590660E-1, 2.624148E-1, 2.624150E-1, 2.750000E-1, 2.759214E-1, 
      2.759216E-1, 2.759623E-1, 2.759625E-1, 2.764012E-1, 2.764014E-1, 2.773607E-1, 
      2.773609E-1, 2.804782E-1, 2.804784E-1, 2.847383E-1, 2.847385E-1, 2.937500E-1, 
      2.997084E-1, 2.997086E-1, 3.004029E-1, 3.004031E-1, 3.028017E-1, 3.028019E-1, 
      3.079730E-1, 3.079732E-1, 3.125000E-1, 3.237259E-1, 3.237261E-1, 3.237816E-1, 
      3.237818E-1, 3.253808E-1, 3.253810E-1, 3.260363E-1, 3.260365E-1, 3.312500E-1, 
      3.321188E-1, 3.321190E-1, 3.493184E-1, 3.493186E-1, 3.500000E-1, 3.501821E-1, 
      3.501823E-1, 3.571758E-1, 3.571760E-1, 3.752140E-1, 3.752142E-1, 3.752391E-1, 
      3.752393E-1, 3.831439E-1, 3.831441E-1, 3.875000E-1, 4.023090E-1, 4.023092E-1, 
      4.024057E-1, 4.024059E-1, 4.026846E-1, 4.026848E-1, 4.035084E-1, 4.035086E-1, 
      4.035725E-1, 4.035727E-1, 4.043722E-1, 4.043724E-1, 4.100232E-1, 4.100234E-1, 
      4.250000E-1, 4.313621E-1, 4.313623E-1, 4.313862E-1, 4.313864E-1, 4.366217E-1, 
      4.366219E-1, 4.378137E-1, 4.378139E-1, 4.598322E-1, 4.598324E-1, 4.603594E-1, 
      4.603596E-1, 4.608559E-1, 4.608561E-1, 4.613189E-1, 4.613191E-1, 4.622784E-1, 
      4.622786E-1, 4.665153E-1, 4.665155E-1, 4.899248E-1, 4.899250E-1, 4.946888E-1, 
      4.946890E-1, 4.960398E-1, 4.960400E-1, 4.961281E-1, 4.961283E-1, 5.000000E-1, 
      5.212158E-1, 5.212160E-1, 5.229191E-1, 5.229193E-1, 5.266521E-1, 5.266523E-1, 
      5.533138E-1, 5.533140E-1, 5.533947E-1, 5.533949E-1, 5.580872E-1, 5.580874E-1, 
      5.861408E-1, 5.861410E-1, 5.862839E-1, 5.862841E-1, 5.904335E-1, 5.904337E-1, 
      6.202685E-1, 6.202687E-1, 6.203326E-1, 6.203328E-1, 6.211322E-1, 6.211324E-1, 
      6.236909E-1, 6.236911E-1, 6.249999E-1, 6.250000E-1, 6.250001E-1, 2.000000E+7 };
      std::vector<double> correct_finalXS { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 7.393697, 7.185991, 6.736867, 
      6.159421, 5.673151, 5.258042, 4.899540, 4.586803, 4.311595, 4.067542, 
      3.849638, 3.477093, 3.286091, 3.286089, 3.170290, 2.983665, 3.330651, 
      3.252037, 3.025431, 4.820561, 4.793004, 4.511062, 4.260448, 4.036214, 
      3.834403, 3.781069, 4.191728, 3.864414, 3.644772, 4.525214, 4.398089, 
      4.059774, 3.828390, 4.590127, 4.519869, 4.218544, 3.954885, 3.722245, 
      3.515454, 3.472387, 3.472381, 3.350141, 3.504040, 3.483429, 3.309257, 
      3.053386, 4.039530, 3.980042, 3.908110, 3.908104, 3.648372, 3.560587, 
      5.166540, 4.992587, 5.277262, 5.165345, 5.117814, 5.358416, 5.021889, 
      4.979850, 4.979845, 4.865274, 4.903729, 4.783099, 5.004494, 4.942820, 
      4.660540, 4.726060, 4.699044, 4.510331, 5.479543, 5.458601, 5.518782, 
      5.413137, 5.208331, 5.372044, 5.333564, 5.333560, 5.256676, 4.966161, 
      4.774575, 4.774571, 4.706076, 4.696306, 4.739664, 4.477127, 4.594987, 
      4.594232, 4.344391, 4.229707, 4.320346, 4.276978, 4.377152, 4.304726, 
      4.823510, 4.589567, 4.569846, 4.599306, 4.533965, 4.706284, 4.513894, 
      4.567196, 4.534662, 4.560972, 4.456265, 4.481495, 4.468760, 4.325032, 
      4.466990, 4.447077, 4.447075, 4.322819, 4.322817, 4.236947, 4.100784, 
      4.141242, 3.988801, 4.045418, 4.019970, 4.169190, 4.159470, 4.122976, 
      4.122974, 4.091137, 4.145156, 4.042965, 4.317921, 4.293668, 4.565730, 
      4.534340, 4.635047, 4.547834, 4.454551, 4.454549, 4.374823, 4.414944, 
      4.287487, 4.259517, 4.273565, 4.210151, 4.428574, 4.421201, 4.448415, 
      4.271527, 4.265217, 4.277760, 4.032085, 3.971580, 4.122992, 4.045650, 
      4.076981, 4.065155, 4.389257, 4.301500, 4.150942, 4.150941, 4.121556, 
      4.130708, 4.102768, 4.301339, 4.281827, 4.262717, 4.461601, 4.257524, 
      4.236776, 4.284631, 4.273751, 4.273749, 4.229718, 4.237484, 4.109448, 
      4.185064, 3.993540, 3.933481, 4.074058, 4.055476, 4.201846, 3.977442, 
      4.010480, 3.961055, 3.858508, 3.954036, 3.757086, 3.784866, 3.774587, 
      3.762589, 3.865139, 3.671805, 3.675877, 3.658830, 3.791125, 3.734829, 
      3.659794, 3.698877, 3.523066, 3.520821, 3.742820, 3.549009, 3.595325, 
      3.556955, 3.507482, 3.603147, 3.564657, 3.663723, 3.534618, 3.473347, 
      3.487511, 3.472114, 3.486124, 3.468520, 3.567883, 3.461817, 3.394882, 
      3.400978, 3.345267, 3.415814, 3.354804, 3.246728, 3.284118, 3.250042, 
      3.303500, 3.295645, 3.315189, 3.296239, 3.234687, 3.268284, 3.203953, 
      3.262846, 3.220065, 3.258012, 3.119709, 3.101026, 3.120996, 3.083939, 
      3.085142, 3.076361, 3.131409, 3.094767, 3.098222, 3.074522, 3.101520, 
      3.007810, 3.055013, 3.006306, 2.898100, 2.899892, 2.885225, 2.886991, 
      2.870848, 2.970384, 2.874810, 2.840466, 2.893839, 2.735897, 2.737178, 
      2.724657, 2.781143, 2.777317, 2.667090, 2.736199, 2.659333, 2.600700, 
      2.644805, 2.535408, 2.531663, 2.532074, 2.524320, 2.563040, 2.437936, 
      2.443477, 2.440707, 2.452431, 2.425115, 2.425778, 2.418818, 2.418816, 
      2.408231, 2.423140, 2.386052, 2.383603, 2.384824, 2.368315, 2.407972, 
      2.283487, 2.284975, 2.283572, 2.300597, 2.261210, 2.266250, 2.258792, 
      2.248711, 2.251178, 2.228408, 2.260182, 2.152062, 2.152060, 2.140434, 
      2.147688, 2.132904, 2.109721, 2.122227, 2.095144, 2.120917, 2.023856, 
      2.017098, 2.017881, 2.017583, 2.019671, 2.016466, 2.022014, 2.015020, 
      2.018661, 1.996225, 2.000857, 1.970922, 1.992775, 1.931642, 1.893240, 
      1.893799, 1.889422, 1.892922, 1.877927, 1.887473, 1.855781, 1.871175, 
      1.844070, 1.780122, 1.782274, 1.781969, 1.783106, 1.774343, 1.774931, 
      1.771364, 1.775630, 1.747684, 1.743112, 1.754724, 1.668327, 1.669940, 
      1.666689, 1.665822, 1.668468, 1.635800, 1.648990, 1.569717, 1.569784, 
      1.569680, 1.573489, 1.541027, 1.548904, 1.531493, 1.475118, 1.475166, 
      1.474812, 1.474860, 1.473839, 1.474607, 1.471598, 1.471668, 1.471435, 
      1.471813, 1.468903, 1.471065, 1.450792, 1.457261, 1.405908, 1.385173, 
      1.385172, 1.385095, 1.387165, 1.370533, 1.370798, 1.367067, 1.371783, 
      1.306097, 1.306120, 1.304625, 1.304695, 1.303290, 1.303290, 1.301982, 
      1.302052, 1.299350, 1.300237, 1.288429, 1.292487, 1.230730, 1.230955, 
      1.219101, 1.219503, 1.216182, 1.216204, 1.215988, 1.219432, 1.209989, 
      1.160738, 1.160794, 1.157013, 1.157250, 1.149048, 1.151478, 1.095994, 
      1.096056, 1.095896, 1.096147, 1.086931, 1.088681, 1.036575, 1.036661, 
      1.036408, 1.036618, 1.029333, 1.030624, 0.9810508, 0.9810541, 0.9809531, 
      0.9809528, 0.9796903, 0.9797975, 0.9757782, 0.9757884, 0.9737450, 0.9737449, 
      0.0, 0.0 };

      auto out = coh(temp,lat,emax,numAtoms,eGrid,tol);
      std::vector<double> finalE  = std::get<0>(out),
                          finalXS = std::get<1>(out),
                          addedE  = std::get<2>(out);

      THEN ( "final energies and xs value must match AND " 
             "each finalE energy value must be in *either* eGrid or addedE" ){
        REQUIRE( ranges::equal(finalE,correct_finalE,equal) );
        REQUIRE( ranges::equal(finalXS,correct_finalXS,equal) );
        checkAddedEnergies( finalE, eGrid, addedE );
      }

    } // WHEN

    WHEN( "Hot temp (500 K), strict tolerance (1e-3), medium max energy (0.9eV)" ){
      double temp = 500.0, emax = 0.9;
      int lat = 1, numAtoms = 1;
      double tol = 1e-3;
     
      std::vector<double> correct_finalE;
      correct_finalE = { 1.E-5, 1.0625E-5, 1.125E-5, 1.1875E-5, 1.25E-5, 
      1.375E-5, 1.5E-5, 1.625E-5, 1.75E-5, 1.875E-5, 2.E-5, 2.1875E-5, 2.375E-5, 
      2.5625E-5, 2.75E-5, 2.9375E-5, 3.125E-5, 3.3125E-5, 3.5E-5, 3.875E-5, 
      4.25E-5, 4.625E-5, 5.E-5, 5.3125E-5, 5.625E-5, 5.9375E-5, 6.25E-5, 6.875E-5, 
      7.5E-5, 8.125E-5, 8.75E-5, 9.375E-5, 1.E-4, 1.0625E-4, 1.125E-4, 1.1875E-4, 
      1.25E-4, 1.375E-4, 1.5E-4, 1.625E-4, 1.75E-4, 1.875E-4, 2.E-4, 2.1875E-4, 
      2.375E-4, 2.5625E-4, 2.75E-4, 2.9375E-4, 3.125E-4, 3.3125E-4, 3.5E-4, 
      3.875E-4, 4.25E-4, 4.555814E-4, 4.555816E-4, 4.625E-4, 5.E-4, 5.3125E-4, 
      5.625E-4, 5.9375E-4, 6.25E-4, 6.875E-4, 7.5E-4, 8.125E-4, 8.75E-4, 9.375E-4, 
      1.E-3, 1.0625E-3, 1.125E-3, 1.1875E-3, 1.25E-3, 1.375E-3, 1.5E-3, 1.625E-3, 
      1.75E-3, 1.822325E-3, 1.822327E-3, 1.875E-3, 1.9375E-3, 2.E-3, 2.09375E-3, 
      2.1875E-3, 2.28125E-3, 2.375E-3, 2.46875E-3, 2.5625E-3, 2.65625E-3, 2.75E-3, 
      2.84375E-3, 2.9375E-3, 3.125E-3, 3.3125E-3, 3.5E-3, 3.6875E-3, 3.875E-3, 
      4.100232E-3, 4.100234E-3, 4.25E-3, 4.515834E-3, 4.515836E-3, 4.625E-3, 
      4.798208E-3, 4.971415E-3, 4.971417E-3, 5.E-3, 5.3125E-3, 5.625E-3, 5.9375E-3, 
      6.25E-3, 6.33816E-3, 6.338162E-3, 6.606581E-3, 6.875E-3, 7.289303E-3, 
      7.289305E-3, 7.5E-3, 7.8125E-3, 8.125E-3, 8.616067E-3, 8.616069E-3, 8.75E-3, 
      9.0625E-3, 9.375E-3, 9.6875E-3, 1.E-2, 1.0625E-2, 1.125E-2, 1.138953E-2, 
      1.138955E-2, 1.180513E-2, 1.180515E-2, 1.1875E-2, 1.25E-2, 1.302375E-2, 
      1.354749E-2, 1.354751E-2, 1.375E-2, 1.400308E-2, 1.40031E-2, 1.450155E-2, 
      1.5E-2, 1.536982E-2, 1.536984E-2, 1.590536E-2, 1.590538E-2, 1.625E-2, 
      1.640092E-2, 1.640094E-2, 1.695047E-2, 1.75E-2, 1.764773E-2, 1.764775E-2, 
      1.806333E-2, 1.806335E-2, 1.851891E-2, 1.851893E-2, 1.875E-2, 1.988565E-2, 
      1.988567E-2, 2.E-2, 2.08368E-2, 2.083682E-2, 2.091676E-2, 2.091678E-2, 
      2.1325E-2, 2.216356E-2, 2.216358E-2, 2.232348E-2, 2.23235E-2, 2.265E-2, 
      2.3975E-2, 2.493703E-2, 2.493705E-2, 2.53E-2, 2.535263E-2, 2.535265E-2, 
      2.683932E-2, 2.683934E-2, 2.684375E-2, 2.83875E-2, 2.91572E-2, 2.915722E-2, 
      2.945287E-2, 2.945289E-2, 2.994843E-2, 2.994845E-2, 3.1475E-2, 3.161083E-2, 
      3.161085E-2, 3.206641E-2, 3.206643E-2, 3.343316E-2, 3.343318E-2, 3.367304E-2, 
      3.367306E-2, 3.446426E-2, 3.446428E-2, 3.45625E-2, 3.571107E-2, 3.571109E-2, 
      3.587099E-2, 3.587101E-2, 3.690209E-2, 3.690211E-2, 3.765E-2, 3.890014E-2, 
      3.890016E-2, 4.038682E-2, 4.038684E-2, 4.06425E-2, 4.064252E-2, 4.07375E-2, 
      4.109808E-2, 4.10981E-2, 4.141792E-2, 4.141794E-2, 4.246483E-2, 4.246485E-2, 
      4.270471E-2, 4.270473E-2, 4.300037E-2, 4.300039E-2, 4.3825E-2, 4.474274E-2, 
      4.474276E-2, 4.555814E-2, 4.555816E-2, 4.69125E-2, 4.722054E-2, 4.722056E-2, 
      4.793181E-2, 4.793183E-2, 4.801177E-2, 4.801179E-2, 5.E-2, 5.007397E-2, 
      5.007399E-2, 5.3125E-2, 5.393433E-2, 5.393435E-2, 5.496543E-2, 5.496545E-2, 
      5.512535E-2, 5.512537E-2, 5.625E-2, 5.829024E-2, 5.829026E-2, 5.870584E-2, 
      5.870586E-2, 5.910564E-2, 5.910566E-2, 5.9375E-2, 5.964118E-2, 5.96412E-2, 
      6.25E-2, 6.280607E-2, 6.280609E-2, 6.296599E-2, 6.296601E-2, 6.362148E-2, 
      6.36215E-2, 6.560372E-2, 6.560374E-2, 6.875E-2, 6.979972E-2, 6.979974E-2, 
      7.011956E-2, 7.011958E-2, 7.407567E-2, 7.407569E-2, 7.5E-2, 7.699326E-2, 
      7.699328E-2, 8.102933E-2, 8.102935E-2, 8.125E-2, 8.150909E-2, 8.150911E-2, 
      8.580085E-2, 8.580087E-2, 8.620065E-2, 8.620067E-2, 8.75E-2, 8.929396E-2, 
      8.929398E-2, 9.375E-2, 9.380979E-2, 9.380981E-2, 9.893275E-2, 9.893277E-2, 
      0.1, 0.1014105, 0.1014107, 0.1025057, 0.1025059, 0.1062500, 0.1081243, 
      0.1081245, 0.1086040, 0.1086042, 0.1091554, 0.1091556, 0.1125000, 0.1147181, 
      0.1147183, 0.1166288, 0.1166290, 0.1187500, 0.1227029, 0.1227031, 0.1239896, 
      0.1239898, 0.1242853, 0.1242855, 0.1250000, 0.1273786, 0.1273788, 0.1299364, 
      0.1299366, 0.1316629, 0.1316631, 0.1375000, 0.1383284, 0.1383286, 0.1399908, 
      0.1399910, 0.1403906, 0.1403908, 0.1420530, 0.1420532, 0.1431482, 0.1431484, 
      0.1476083, 0.1476085, 0.1500000, 0.1556005, 0.1556007, 0.1563917, 0.1563919, 
      0.1572713, 0.1572715, 0.1625000, 0.1644648, 0.1644650, 0.1739595, 0.1739597, 
      0.1747591, 0.1747593, 0.1750000, 0.1822325, 0.1822327, 0.1875000, 0.1917272, 
      0.1917274, 0.2000000, 0.2002958, 0.2002960, 0.2009113, 0.2009115, 0.2112214, 
      0.2112216, 0.2114613, 0.2114615, 0.2138433, 0.2138435, 0.2144588, 0.2144590, 
      0.2154016, 0.2154018, 0.2187500, 0.2189747, 0.2189749, 0.2205013, 0.2205015, 
      0.2325222, 0.2325224, 0.2326653, 0.2326655, 0.2367182, 0.2367184, 0.2375000, 
      0.2385647, 0.2385649, 0.2410025, 0.2410027, 0.2531107, 0.2531109, 0.2544858, 
      0.2544860, 0.2562500, 0.2590658, 0.2590660, 0.2624148, 0.2624150, 0.2750000, 
      0.2759214, 0.2759216, 0.2759623, 0.2759625, 0.2764012, 0.2764014, 0.2773607, 
      0.2773609, 0.2804782, 0.2804784, 0.2847383, 0.2847385, 0.2937500, 0.2997084, 
      0.2997086, 0.3004029, 0.3004031, 0.3028017, 0.3028019, 0.3079730, 0.3079732, 
      0.3125000, 0.3237259, 0.3237261, 0.3237816, 0.3237818, 0.3253808, 0.3253810, 
      0.3260363, 0.3260365, 0.3312500, 0.3321188, 0.3321190, 0.3493184, 0.3493186, 
      0.3500000, 0.3501821, 0.3501823, 0.3571758, 0.3571760, 0.3752140, 0.3752142, 
      0.3752391, 0.3752393, 0.3831439, 0.3831441, 0.3875000, 0.4023090, 0.4023092, 
      0.4024057, 0.4024059, 0.4026846, 0.4026848, 0.4035084, 0.4035086, 0.4035725, 
      0.4035727, 0.4043722, 0.4043724, 0.4100232, 0.4100234, 0.4250000, 0.4313621, 
      0.4313623, 0.4313862, 0.4313864, 0.4366217, 0.4366219, 0.4378137, 0.4378139, 
      0.4598322, 0.4598324, 0.4603594, 0.4603596, 0.4608559, 0.4608561, 0.4613189, 
      0.4613191, 0.4622784, 0.4622786, 0.4665153, 0.4665155, 0.4899248, 0.4899250, 
      0.4946888, 0.4946890, 0.4960398, 0.4960400, 0.4961281, 0.4961283, 0.5000000, 
      0.5212158, 0.5212160, 0.5229191, 0.5229193, 0.5266521, 0.5266523, 0.5533138, 
      0.5533140, 0.5533947, 0.5533949, 0.5580872, 0.5580874, 0.5861408, 0.5861410, 
      0.5862839, 0.5862841, 0.5904335, 0.5904337, 0.6202685, 0.6202687, 0.6203326, 
      0.6203328, 0.6211322, 0.6211324, 0.6236909, 0.6236911, 0.6250000, 0.6553018, 
      0.6553020, 0.6575694, 0.6575696, 0.6578595, 0.6578597, 0.6916264, 0.6916266, 
      0.6925860, 0.6925862, 0.6929393, 0.6929395, 0.7279456, 0.7279458, 0.7286485, 
      0.7286487, 0.7289303, 0.7289305, 0.7500000, 0.7658324, 0.7658326, 0.8052029, 
      0.8052031, 0.8058352, 0.8058354, 0.8064749, 0.8064751, 0.8081615, 0.8081617, 
      0.8423700, 0.8423702, 0.8750000, 0.8851035, 0.8851037, 0.8865215, 0.8865217, 
      0.8999999, 0.9000000, 0.9000001, 2.E7 };
      std::vector<double> correct_finalXS;
      correct_finalXS = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 7.334602, 7.128556, 6.898603, 6.683022, 
      6.383782, 6.110191, 5.859087, 5.627808, 5.414093, 5.216017, 5.031922, 
      4.860379, 4.700147, 4.550142, 4.277134, 4.035032, 3.818869, 3.624690, 
      3.449301, 3.259826, 3.259824, 3.144951, 2.959817, 3.299971, 3.222082, 
      3.105770, 2.997563, 4.753821, 4.726645, 4.448607, 4.201463, 3.980333, 
      3.781316, 3.728720, 4.128076, 3.960356, 3.805733, 3.589426, 4.442056, 
      4.317267, 4.144576, 3.985169, 3.758037, 4.491414, 4.422667, 4.270161, 
      4.127822, 3.994667, 3.869833, 3.642196, 3.439852, 3.397711, 3.397705, 
      3.278095, 3.424197, 3.404055, 3.233853, 3.103803, 2.983812, 3.912846, 
      3.855223, 3.785547, 3.785541, 3.655424, 3.533954, 3.448922, 4.949778, 
      4.783123, 5.048542, 4.941475, 4.896004, 5.119841, 4.953857, 4.798298, 
      4.758131, 4.758126, 4.648656, 4.684170, 4.568941, 4.772998, 4.714177, 
      4.444955, 4.504981, 4.479228, 4.299344, 5.183582, 5.163771, 5.218656, 
      5.118757, 4.925088, 5.073578, 5.037236, 5.037232, 4.964620, 4.690246, 
      4.509304, 4.509300, 4.444611, 4.435384, 4.474162, 4.226331, 4.331052, 
      4.330341, 4.094851, 3.986754, 4.066471, 4.025652, 4.113641, 4.045575, 
      4.500260, 4.281996, 4.263596, 4.289228, 4.228292, 4.377918, 4.198951, 
      4.244956, 4.214718, 4.237401, 4.140123, 4.161800, 4.149973, 4.016498, 
      4.137799, 4.119354, 4.119352, 4.004253, 4.004251, 3.924710, 3.798580, 
      3.832669, 3.691587, 3.738979, 3.715459, 3.840226, 3.831272, 3.797658, 
      3.797656, 3.768332, 3.813344, 3.719334, 3.947394, 3.925223, 4.150645, 
      4.122109, 4.205443, 4.126313, 4.041676, 4.041674, 3.969338, 4.002166, 
      3.886625, 3.861271, 3.872681, 3.815215, 3.992077, 3.985430, 4.007457, 
      3.848104, 3.842419, 3.852480, 3.631229, 3.576739, 3.696065, 3.626732, 
      3.651328, 3.640736, 3.893424, 3.815581, 3.682030, 3.682029, 3.655964, 
      3.663031, 3.638255, 3.791310, 3.774112, 3.757268, 3.909244, 3.730432, 
      3.712253, 3.748545, 3.739025, 3.739024, 3.700502, 3.706370, 3.594382, 
      3.650609, 3.483544, 3.431154, 3.534495, 3.518374, 3.625356, 3.431740, 
      3.455428, 3.412843, 3.324489, 3.391962, 3.223009, 3.242452, 3.233646, 
      3.223368, 3.294474, 3.129685, 3.132476, 3.117948, 3.208312, 3.160671, 
      3.097171, 3.123429, 2.974970, 2.973073, 3.118545, 2.957061, 2.986912, 
      2.955035, 2.913934, 2.974953, 2.943174, 3.005632, 2.899718, 2.849452, 
      2.858249, 2.845630, 2.854313, 2.839900, 2.900688, 2.814456, 2.760038, 
      2.763713, 2.718440, 2.760052, 2.710754, 2.623427, 2.645134, 2.617689, 
      2.648654, 2.642356, 2.653588, 2.638420, 2.589152, 2.608198, 2.556860, 
      2.590054, 2.556094, 2.576971, 2.467578, 2.452801, 2.463659, 2.434407, 
      2.435056, 2.428125, 2.457771, 2.429012, 2.430855, 2.412260, 2.426583, 
      2.353265, 2.377638, 2.339730, 2.255517, 2.256419, 2.245006, 2.245892, 
      2.233334, 2.282266, 2.208833, 2.182445, 2.207774, 2.087276, 2.087870, 
      2.078319, 2.104137, 2.101243, 2.017848, 2.048359, 1.990816, 1.946923, 
      1.965698, 1.884391, 1.881608, 1.881777, 1.876014, 1.891722, 1.799385, 
      1.801570, 1.799528, 1.804146, 1.784051, 1.784309, 1.779190, 1.779188, 
      1.771402, 1.777127, 1.749927, 1.748131, 1.748595, 1.736490, 1.751268, 
      1.660733, 1.661267, 1.660247, 1.666313, 1.637785, 1.639550, 1.634154, 
      1.626861, 1.627720, 1.611257, 1.622065, 1.544471, 1.544470, 1.536125, 
      1.538459, 1.527869, 1.511262, 1.515236, 1.495899, 1.503777, 1.434959, 
      1.430167, 1.430398, 1.430187, 1.430806, 1.428535, 1.430173, 1.425227, 
      1.426291, 1.410439, 1.411769, 1.390647, 1.396731, 1.353883, 1.326967, 
      1.327116, 1.324048, 1.324978, 1.314482, 1.316984, 1.294871, 1.298703, 
      1.279890, 1.235507, 1.236024, 1.235812, 1.236084, 1.230010, 1.230149, 
      1.227677, 1.228675, 1.209337, 1.206174, 1.208745, 1.149230, 1.149575, 
      1.147337, 1.146741, 1.147298, 1.124834, 1.127472, 1.073270, 1.073283, 
      1.073211, 1.073923, 1.051767, 1.053163, 1.041324, 1.002993, 1.003001, 
      1.002760, 1.002768, 1.002074, 1.002204, 1.000158, 1.000170, 1.000012, 
      1.000075, 0.9980975, 0.9984579, 0.9846975, 0.9857124, 0.9509768, 0.9369510, 
      0.9369506, 0.9368987, 0.9372049, 0.9259673, 0.9260058, 0.9234850, 0.9241435, 
      0.8798924, 0.8798951, 0.8788879, 0.8788968, 0.8779503, 0.8779500, 0.8770692, 
      0.8770780, 0.8752579, 0.8753721, 0.8674224, 0.8679179, 0.8264475, 0.8264729, 
      0.8185140, 0.8185590, 0.8163300, 0.8163322, 0.8161873, 0.8165524, 0.8102295, 
      0.7772496, 0.7772550, 0.7747236, 0.7747468, 0.7692556, 0.7694839, 0.7324062, 
      0.7324115, 0.7323047, 0.7323261, 0.7261688, 0.7263105, 0.6915484, 0.6915547, 
      0.6913862, 0.6914017, 0.6865427, 0.6866329, 0.6536060, 0.6536060, 0.6535387, 
      0.6535385, 0.6526974, 0.6527041, 0.6500266, 0.6500806, 0.6487192, 0.6187218, 
      0.6187233, 0.6165899, 0.6165908, 0.6163190, 0.6163572, 0.5862653, 0.5862654, 
      0.5854532, 0.5854532, 0.5851549, 0.5851786, 0.5570380, 0.5570386, 0.5565014, 
      0.5565012, 0.5562863, 0.5562991, 0.5406712, 0.5294936, 0.5295023, 0.5036123, 
      0.5036123, 0.5032173, 0.5032172, 0.5028181, 0.5028181, 0.5017689, 0.5017727, 
      0.4813959, 0.4813989, 0.4634470, 0.4581567, 0.4581568, 0.4574241, 0.4574247, 
      0.4505744, 0.4505743, 0, 0 };

      auto out = coh(temp,lat,emax,numAtoms,eGrid,tol);
      std::vector<double> finalE  = std::get<0>(out),
                          finalXS = std::get<1>(out),
                          addedE  = std::get<2>(out);

      THEN ( "final energies and xs value must match AND " 
             "each finalE energy value must be in *either* eGrid or addedE" ){
        REQUIRE( ranges::equal(finalE,correct_finalE,equal) );
        REQUIRE( ranges::equal(finalXS,correct_finalXS,equal) );
        checkAddedEnergies( finalE, eGrid, addedE );
      } // THEN
      
    } // WHEN
  } // GIVEN

  GIVEN( "material is beryllium (lat = 2)" ){
    WHEN( "Room temperature, medium max E, medium tolerance" ){
      double temp = 296.0, emax = 1.025;
      int lat = 2, numAtoms = 1;
      double tol = 5e-2;

      std::vector<double> correct_finalE;
      correct_finalE = { 1.E-5, 1.0625E-5, 1.125E-5, 1.1875E-5, 1.25E-5, 
      1.375E-5, 1.5E-5, 1.625E-5, 1.75E-5, 1.875E-5, 2.E-5, 2.1875E-5, 2.375E-5, 
      2.5625E-5, 2.75E-5, 2.9375E-5, 3.125E-5, 3.3125E-5, 3.5E-5, 3.875E-5, 
      4.25E-5, 4.625E-5, 5.E-5, 5.3125E-5, 5.625E-5, 5.9375E-5, 6.25E-5, 
      6.875E-5, 7.5E-5, 8.125E-5, 8.75E-5, 9.375E-5, 1.E-4, 1.0625E-4, 1.125E-4, 
      1.1875E-4, 1.25E-4, 1.375E-4, 1.5E-4, 1.625E-4, 1.75E-4, 1.875E-4, 2.E-4, 
      2.1875E-4, 2.375E-4, 2.5625E-4, 2.75E-4, 2.9375E-4, 3.125E-4, 3.3125E-4, 
      3.5E-4, 3.875E-4, 4.25E-4, 4.625E-4, 5.E-4, 5.3125E-4, 5.625E-4, 5.9375E-4, 
      6.25E-4, 6.875E-4, 7.5E-4, 8.125E-4, 8.75E-4, 9.375E-4, 1.E-3, 1.0625E-3, 
      1.125E-3, 1.1875E-3, 1.25E-3, 1.375E-3, 1.5E-3, 1.592844E-3, 1.592846E-3, 
      1.625E-3, 1.75E-3, 1.875E-3, 2.E-3, 2.1875E-3, 2.375E-3, 2.5625E-3, 
      2.75E-3, 2.9375E-3, 3.125E-3, 3.3125E-3, 3.5E-3, 3.875E-3, 4.25E-3, 
      4.625E-3, 5.E-3, 5.2198E-3, 5.219802E-3, 5.3125E-3, 5.625E-3, 5.9375E-3, 
      6.25E-3, 6.37138E-3, 6.371382E-3, 6.812645E-3, 6.812647E-3, 6.875E-3, 
      7.5E-3, 8.125E-3, 8.75E-3, 9.375E-3, 1E-2, 1.0625E-2, 1.125E-2, 1.159117E-2, 
      1.159119E-2, 1.1875E-2, 1.25E-2, 1.375E-2, 1.43356E-2, 1.433562E-2, 1.5E-2, 
      1.565939E-2, 1.565941E-2, 1.625E-2, 1.725224E-2, 1.725226E-2, 1.75E-2, 
      1.875E-2, 1.95554E-2, 1.955542E-2, 2.E-2, 2.087919E-2, 2.087921E-2, 
      2.1325E-2, 2.203077E-2, 2.203079E-2, 2.247204E-2, 2.247206E-2, 2.265E-2, 
      2.3975E-2, 2.53E-2, 2.548551E-2, 2.548553E-2, 2.684375E-2, 2.725057E-2, 
      2.725059E-2, 2.83875E-2, 2.9995E-2, 2.999502E-2, 3.070531E-2, 3.070533E-2, 
      3.1475E-2, 3.45625E-2, 3.52148E-2, 3.521482E-2, 3.65386E-2, 3.653862E-2, 
      3.765E-2, 3.813144E-2, 3.813146E-2, 3.982112E-2, 3.982114E-2, 4.07375E-2, 
      4.114492E-2, 4.114494E-2, 4.290998E-2, 4.291E-2, 4.3825E-2, 4.504092E-2, 
      4.504094E-2, 4.636472E-2, 4.636474E-2, 4.69125E-2, 4.69782E-2, 4.697822E-2, 
      4.857104E-2, 4.857106E-2, 5.E-2, 5.3125E-2, 5.334958E-2, 5.33496E-2, 
      5.625E-2, 5.734242E-2, 5.734244E-2, 5.9375E-2, 6.070032E-2, 6.070034E-2, 
      6.25E-2, 6.256222E-2, 6.256224E-2, 6.78574E-2, 6.785742E-2, 6.875E-2, 
      7.246372E-2, 7.246374E-2, 7.5E-2, 7.635973E-2, 7.635975E-2, 7.80494E-2, 
      7.804942E-2, 8.125E-2, 8.219301E-2, 8.219303E-2, 8.32692E-2, 8.326922E-2, 
      8.75E-2, 8.812312E-2, 8.812314E-2, 8.988819E-2, 8.988821E-2, 9.375E-2, 
      9.785241E-2, 9.785243E-2, 9.892861E-2, 9.892863E-2, 0.1, 0.101942, 
      0.1019422, 0.10625, 0.1071618, 0.107162, 0.1125, 0.1135117, 0.1135119, 
      0.1145879, 0.1145881, 0.1176014, 0.1176016, 0.11875, 0.1228212, 0.1228214, 
      0.125, 0.1290204, 0.1290206, 0.1368663, 0.1368665, 0.1375, 0.1408591, 
      0.1408593, 0.1489202, 0.1489204, 0.1498996, 0.1498998, 0.15, 0.1592844, 
      0.1592846, 0.1625, 0.1681851, 0.1681853, 0.1697994, 0.1697996, 0.1703161, 
      0.1703163, 0.175, 0.1759986, 0.1759988, 0.1801636, 0.1801638, 0.1875, 
      0.1895056, 0.1895058, 0.1927342, 0.1927344, 0.2, 0.2034968, 0.203497, 
      0.2062626, 0.2062628, 0.2136134, 0.2136136, 0.21875, 0.2244513, 0.2244515, 
      0.2271418, 0.227142, 0.2277339, 0.2277341, 0.2293696, 0.2293698, 0.2375, 
      0.2428012, 0.2428014, 0.2502488, 0.250249, 0.25625, 0.2637558, 0.263756, 
      0.2659082, 0.2659084, 0.2659621, 0.2659623, 0.2691907, 0.2691909, 0.275, 
      0.2848501, 0.2848503, 0.2897794, 0.2897796, 0.2900699, 0.2900701, 0.29375, 
      0.3054388, 0.305439, 0.3057293, 0.3057295, 0.3121976, 0.3121978, 0.3125, 
      0.327857, 0.3278572, 0.33125, 0.3330768, 0.333077, 0.35, 0.3513194, 
      0.3513196, 0.3527075, 0.3527077, 0.3583901, 0.3583903, 0.3788066,0.3788068, 
      0.3792693, 0.3792695, 0.3875, 0.3982976, 0.3982978, 0.3994706, 0.3994708, 
      0.3996858, 0.399686, 0.4053683, 0.4053685, 0.4077683, 0.4077685, 0.425, 
      0.4286475, 0.4286477, 0.4516687, 0.4516689, 0.453821, 0.4538212, 0.4547465, 
      0.4547467, 0.4603322, 0.4603324, 0.4851399, 0.4851401, 0.4888851,0.4888853, 
      0.4912851, 0.4912853, 0.5, 0.5073104, 0.5073106, 0.5160817, 0.5160819, 
      0.5424608, 0.542461, 0.543849, 0.5438492, 0.5630599, 0.5630601, 0.575017, 
      0.5750172, 0.6040222, 0.6040224, 0.6097262, 0.6097264, 0.6115556,0.6115558, 
      0.6141603, 0.6141605, 0.6219952, 0.6219954, 0.625, 0.637138, 0.6371382, 
      0.669286, 0.6692862, 0.6709003, 0.6709005, 0.6714169, 0.6714171, 0.6812645, 
      0.6812647, 0.6841162, 0.6841164, 0.7024446, 0.7024448, 0.7386823,0.7386825, 
      0.7389832, 0.7389834, 0.7418355, 0.7418357, 0.7494228, 0.749423, 0.75, 
      0.770937, 0.7709372, 0.8100588, 0.810059, 0.8120604, 0.8120606, 0.8179152, 
      0.8179154, 0.842615, 0.8426152, 0.875, 0.8848368, 0.884837, 0.8869677, 
      0.8869679, 0.8885176, 0.8885178, 0.8895932, 0.8895934, 0.9174787,0.9174789, 
      0.9634243, 0.9634245, 0.9644569, 0.9644571, 0.9955281, 0.9955283, 1.0, 
      1.024999, 1.025, 1.025001, 2.E7 }; 
      std::vector<double> correct_finalXS { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 1.609035, 1.580959, 1.493128, 1.414542, 1.343815, 1.318214, 
      2.885851, 2.698931, 9.043268, 8.961250, 8.214479, 7.582596, 7.040982, 
      6.571583, 6.160859, 5.798456, 5.476319, 5.315131, 6.211589, 6.063133, 
      5.759976, 5.236342, 5.022441, 5.022434, 4.799980, 4.597861, 5.681835, 
      5.475334, 5.157254, 5.157248, 5.084239, 4.745290, 4.549852, 5.658406, 
      5.532625, 5.299655, 5.464311, 5.350082, 5.178689, 6.376302, 6.251100, 
      7.118081, 7.062161, 6.671864, 6.322449, 6.276427, 6.429921, 6.104584, 
      6.013450, 6.217046, 5.968055, 5.648214, 5.648210, 5.517553, 5.680424, 
      5.541518, 5.046489, 4.953011, 5.328575, 5.135523, 5.251981, 5.096949, 
      5.032596, 5.674834, 5.434044, 5.434041, 5.311806, 5.259208, 5.626773, 
      5.395324, 5.564035, 5.447867, 5.300797, 5.529800, 5.371916, 5.443777, 
      5.380215, 5.372690, 5.512509, 5.331734, 5.702664, 5.539689, 5.213825, 
      5.191877, 5.404885, 5.126194, 5.028536, 5.058809, 4.885633, 4.778961, 
      4.976503, 4.833207, 4.828400, 4.940116, 4.554621, 4.885245, 4.821820, 
      4.574704, 4.835317, 4.671802, 4.588612, 4.727677, 4.625330, 4.647207, 
      4.464145, 4.412927, 4.528511, 4.469985, 4.589169, 4.367274, 4.336393, 
      4.400739, 4.314326, 4.386653, 4.205957, 4.029624, 4.066047, 4.021815, 
      4.137292, 4.092966, 4.014995, 4.084120, 3.918534, 3.885192, 3.995683, 
      3.806092, 3.772170, 3.819897, 3.784027, 3.890870, 3.791174, 3.847316, 
      3.810109, 3.683814, 3.732977, 3.667916, 3.553620, 3.625366, 3.417546, 
      3.456518, 3.440593, 3.358544, 3.444659, 3.258203, 3.271670, 3.250298, 
      3.275399, 3.273211, 3.082422, 3.180329, 3.117400, 3.012024, 3.016408, 
      2.987734, 2.991968, 2.982894, 3.001073, 2.920752, 2.904180, 2.926196, 
      2.858552, 2.878680, 2.766048, 2.736774, 2.736771, 2.690929, 2.734704, 
      2.635358, 2.590073, 2.596365, 2.561552, 2.595369, 2.506061, 2.519216, 
      2.460063, 2.397575, 2.402329, 2.373875, 2.375190, 2.369016, 2.381809, 
      2.364826, 2.377770, 2.296373, 2.246235, 2.254215, 2.187130, 2.202800, 
      2.151213, 2.089996, 2.092615, 2.075678, 2.076309, 2.075890, 2.078313, 
      2.053388, 2.066950, 2.023288, 1.953322, 1.954649, 1.921400, 1.922424, 
      1.920500, 1.930920, 1.906731, 1.833762, 1.835312, 1.833569, 1.835949, 
      1.797912, 1.802251, 1.800508, 1.716171, 1.718004, 1.700407, 1.691081, 
      1.696350, 1.614329, 1.608267, 1.609099, 1.602767, 1.605543, 1.580087, 
      1.582709, 1.497407, 1.497406, 1.495580, 1.498408, 1.466582, 1.426824, 
      1.427014, 1.422825, 1.423074, 1.422308, 1.422645, 1.402703, 1.402813, 
      1.394557, 1.396724, 1.340094, 1.328691, 1.330047, 1.262256, 1.262414, 
      1.256427, 1.256478, 1.253921, 1.254239, 1.239021, 1.239814, 1.176416, 
      1.176530, 1.167518, 1.167670, 1.161967, 1.162337, 1.142078, 1.125621, 
      1.125888, 1.106753, 1.107184, 1.053344, 1.053388, 1.050700, 1.050899, 
      1.015044, 1.015119, 0.9940108, 0.9942214, 0.9464792, 0.9465270, 0.9376725, 
      0.9376990, 0.9348943, 0.9349006, 0.9309359, 0.9309751, 0.9192485, 0.9193021, 
      0.9148827, 0.8974534, 0.8975451, 0.8544333, 0.8544340, 0.8523783, 0.8523789, 
      0.8517234, 0.8517402, 0.8394286, 0.8394341, 0.8359352, 0.8359575, 0.8141457, 
      0.8141901, 0.7742484, 0.7742495, 0.7739345, 0.7739384, 0.7709629, 0.7709664, 
      0.7631612, 0.7631710, 0.7625838, 0.7418737, 0.7418906, 0.7060612, 0.7060613, 
      0.7043212, 0.7043222, 0.6992807, 0.6992875, 0.6787893, 0.6787945, 0.6536715, 
      0.6464046, 0.6464045, 0.6448517, 0.6448519, 0.6437271, 0.6437271, 0.6429489, 
      0.6429513, 0.6234098, 0.6234120, 0.5936817, 0.5936817, 0.5930462, 0.5930470, 
      0.5745376, 0.5745380, 0.5719689, 0.5580190, 0.5580184, 0, 0 };

      auto out = coh(temp,lat,emax,numAtoms,eGrid,tol);
      std::vector<double> finalE  = std::get<0>(out),
                          finalXS = std::get<1>(out),
                          addedE  = std::get<2>(out);

      THEN ( "final energies and xs value must match AND " 
             "each finalE energy value must be in *either* eGrid or addedE" ){
        REQUIRE( ranges::equal(finalE,correct_finalE,equal) );
        REQUIRE( ranges::equal(finalXS,correct_finalXS,equal) );
        checkAddedEnergies( finalE, eGrid, addedE );
      } // THEN
 
      
    } // WHEN

    WHEN( "Higher temp (400K), medium  max E (1eV), high tolerance (1.0)" ){
      double temp = 400.0, emax = 1.0;
      int lat = 2, numAtoms = 1;
      double tol = 1e0;

      std::vector<double> correct_finalE;
      correct_finalE = { 1.000E-5, 1.0625E-5, 1.125E-5, 1.1875E-5, 1.250E-5, 
      1.375E-5, 1.500E-5, 1.625E-5, 1.750E-5, 1.875E-5, 2.000E-5, 2.1875E-5, 
      2.375E-5, 2.5625E-5, 2.750E-5, 2.9375E-5, 3.125E-5, 3.3125E-5, 3.500E-5, 
      3.875E-5, 4.250E-5, 4.625E-5, 5.000E-5, 5.3125E-5, 5.625E-5, 5.9375E-5, 
      6.25E-5, 6.875E-5, 7.500E-5, 8.125E-5, 8.750E-5, 9.375E-5, 1.000E-4, 
      1.0625E-4,1.125E-4, 1.1875E-4, 1.250E-4, 1.375E-4, 1.500E-4, 1.625E-4, 
      1.75E-4, 1.875E-4, 2.000E-4, 2.1875E-4, 2.375E-4, 2.5625E-4, 2.750E-4, 
      2.9375E-4,3.125E-4, 3.3125E-4, 3.500E-4, 3.875E-4, 4.250E-4, 4.625E-4, 
      5.00E-4, 5.3125E-4, 5.625E-4, 5.9375E-4, 6.250E-4, 6.875E-4, 7.500E-4, 
      8.125E-4, 8.750E-4, 9.375E-4, 1.000E-3, 1.0625E-3, 1.125E-3, 1.1875E-3, 
      1.25E-3, 1.375E-3, 1.5E-3, 1.592844E-3, 1.592846E-3, 1.625E-3, 1.750E-3, 
      1.875E-3, 2.000E-3, 2.1875E-3, 2.375E-3, 2.5625E-3, 2.750E-3, 2.9375E-3, 
      3.125E-3, 3.3125E-3, 3.500E-3, 3.875E-3, 4.250E-3, 4.625E-3, 5.000E-3, 
      5.2198E-3, 5.219802E-3, 5.3125E-3, 5.625E-3, 5.9375E-3, 6.25E-3, 6.37138E-3, 
      6.371382E-3, 6.812645E-3, 6.812647E-3, 6.875E-3, 7.5E-3, 8.125E-3, 8.75E-3, 
      9.375E-3, 1E-2, 1.0625E-2, 1.125E-2, 1.159117E-2, 1.159119E-2, 1.1875E-2, 
      1.250E-2, 1.375E-2, 1.43356E-2, 1.433562E-2, 1.5E-2, 1.565939E-2, 
      1.565941E-2, 1.625E-2, 1.725224E-2, 1.725226E-2, 1.750E-2, 1.875E-2, 
      1.95554E-2, 1.955542E-2, 2.E-2, 2.087919E-2, 2.087921E-2, 2.1325E-2, 
      2.203077E-2, 2.203079E-2, 2.247204E-2, 2.247206E-2, 2.265E-2, 2.3975E-2, 
      2.530E-2, 2.548551E-2, 2.548553E-2, 2.684375E-2, 2.725057E-2, 2.725059E-2, 
      2.83875E-2, 2.9995E-2, 2.999502E-2, 3.070531E-2, 3.070533E-2, 3.1475E-2, 
      3.45625E-2, 3.52148E-2, 3.521482E-2, 3.65386E-2, 3.653862E-2, 3.765E-2, 
      3.813144E-2, 3.813146E-2, 3.982112E-2, 3.982114E-2, 4.07375E-2, 4.114492E-2, 
      4.114494E-2, 4.290998E-2, 4.291E-2, 4.3825E-2, 4.504092E-2, 4.504094E-2, 
      4.636472E-2, 4.636474E-2, 4.69125E-2, 4.69782E-2, 4.697822E-2, 4.857104E-2, 
      4.857106E-2, 5.E-2, 5.3125E-2, 5.334958E-2, 5.33496E-2, 5.625E-2, 
      5.734242E-2, 5.734244E-2, 5.9375E-2, 6.070032E-2, 6.070034E-2, 6.250E-2, 
      6.256222E-2, 6.256224E-2, 6.78574E-2, 6.785742E-2, 6.875E-2, 7.246372E-2, 
      7.246374E-2, 7.5E-2, 7.635973E-2, 7.635975E-2, 7.80494E-2, 7.804942E-2, 
      8.125E-2, 8.219301E-2, 8.219303E-2, 8.32692E-2, 8.326922E-2, 8.750E-2, 
      8.812312E-2, 8.812314E-2, 8.988819E-2, 8.988821E-2, 9.375E-2, 9.785241E-2, 
      9.785243E-2, 9.892861E-2, 9.892863E-2, 0.1000000, 0.1019420, 0.1019422, 
      0.1062500, 0.1071618, 0.1071620, 0.1125000, 0.1135117, 0.1135119, 
      0.1145879, 0.1145881, 0.1176014, 0.1176016, 0.1187500, 0.1228212, 0.1228214, 
      0.1250000, 0.1290204, 0.1290206, 0.1368663, 0.1368665, 0.1375000, 0.1408591, 
      0.1408593, 0.1489202, 0.1489204, 0.1498996, 0.1498998, 0.1500000, 0.1592844, 
      0.1592846, 0.1625000, 0.1681851, 0.1681853, 0.1697994, 0.1697996, 0.1703161, 
      0.1703163, 0.1750000, 0.1759986, 0.1759988, 0.1801636, 0.1801638, 0.1875000, 
      0.1895056, 0.1895058, 0.1927342, 0.1927344, 0.2000000, 0.2034968, 0.2034970, 
      0.2062626, 0.2062628, 0.2136134, 0.2136136, 0.2187500, 0.2244513, 0.2244515, 
      0.2271418, 0.2271420, 0.2277339, 0.2277341, 0.2293696, 0.2293698, 0.2375000, 
      0.2428012, 0.2428014, 0.2502488, 0.2502490, 0.2562500, 0.2637558, 0.2637560, 
      0.2659082, 0.2659084, 0.2659621, 0.2659623, 0.2691907, 0.2691909, 0.2750000, 
      0.2848501, 0.2848503, 0.2897794, 0.2897796, 0.2900699, 0.2900701, 0.2937500, 
      0.3054388, 0.3054390, 0.3057293, 0.3057295, 0.3121976, 0.3121978, 0.3125000, 
      0.3278570, 0.3278572, 0.3312500, 0.3330768, 0.3330770, 0.3500000, 0.3513194, 
      0.3513196, 0.3527075, 0.3527077, 0.3583901, 0.3583903, 0.3788066, 0.3788068, 
      0.3792693, 0.3792695, 0.3875000, 0.3982976, 0.3982978, 0.3994706, 0.3994708, 
      0.3996858, 0.3996860, 0.4053683, 0.4053685, 0.4077683, 0.4077685, 0.4250000, 
      0.4286475, 0.4286477, 0.4516687, 0.4516689, 0.4538210, 0.4538212, 0.4547465, 
      0.4547467, 0.4603322, 0.4603324, 0.4851399, 0.4851401, 0.4888851, 0.4888853, 
      0.4912851, 0.4912853, 0.5000000, 0.5073104, 0.5073106, 0.5160817, 0.5160819, 
      0.5424608, 0.5424610, 0.5438490, 0.5438492, 0.5630599, 0.5630601, 0.5750170, 
      0.5750172, 0.6040222, 0.6040224, 0.6097262, 0.6097264, 0.6115556, 0.6115558, 
      0.6141603, 0.6141605, 0.6219952, 0.6219954, 0.6250000, 0.6371380, 0.6371382, 
      0.6692860, 0.6692862, 0.6709003, 0.6709005, 0.6714169, 0.6714171, 0.6812645, 
      0.6812647, 0.6841162, 0.6841164, 0.7024446, 0.7024448, 0.7386823, 0.7386825, 
      0.7389832, 0.7389834, 0.7418355, 0.7418357, 0.7494228, 0.7494230, 0.7500000, 
      0.7709370, 0.7709372, 0.8100588, 0.8100590, 0.8120604, 0.8120606, 0.8179152, 
      0.8179154, 0.8426150, 0.8426152, 0.8750000, 0.8848368, 0.8848370, 0.8869677, 
      0.8869679, 0.8885176, 0.8885178, 0.8895932, 0.8895934, 0.9174787, 0.9174789, 
      0.9634243, 0.9634245, 0.9644569, 0.9644571, 0.9955281, 0.9955283, 0.9999990, 
      1.0, 1.000001, 2E7 };
      std::vector<double> correct_finalXS;
      correct_finalXS = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.584763, 
      1.557110, 1.470604, 1.393204, 1.323543, 1.298329, 2.837148, 2.653383, 
      8.873098, 8.792624, 8.059905, 7.439912, 6.908490, 6.447924, 6.044929, 
      5.689345, 5.373270, 5.215115, 6.081819, 5.936465, 5.639641, 5.126947, 
      4.917514, 4.917507, 4.699701, 4.501805, 5.537459, 5.336205, 5.026208, 
      5.026202, 4.955048, 4.624711, 4.434240, 5.481430, 5.359583, 5.133900, 
      5.288843, 5.178282, 5.012392, 6.135587, 6.015112, 6.827175, 6.773540, 
      6.399194, 6.064058, 6.019918, 6.162432, 5.850630, 5.763287, 5.951351, 
      5.713001, 5.406829, 5.406825, 5.281752, 5.430692, 5.297893, 4.824627, 
      4.735259, 5.074219, 4.890382, 4.995085, 4.847637, 4.786431, 5.361172, 
      5.133691, 5.133688, 5.018210, 4.968519, 5.294581, 5.076796, 5.225690, 
      5.116585, 4.978458, 5.179312, 5.031435, 5.094220, 5.034739, 5.027698, 
      5.149640, 4.980764, 5.300619, 5.149134, 4.846244, 4.825843, 5.008202, 
      4.749965, 4.659475, 4.685092, 4.524709, 4.425917, 4.591203, 4.459001, 
      4.454567, 4.547663, 4.192792, 4.463122, 4.405177, 4.179415, 4.390105, 
      4.241646, 4.166115, 4.277455, 4.184854, 4.202275, 4.036740, 3.990426, 
      4.081407, 4.028659, 4.121948, 3.922644, 3.894907, 3.944689, 3.867231, 
      3.922428, 3.760854, 3.603182, 3.630574, 3.591079, 3.677372, 3.637973, 
      3.568670, 3.619668, 3.472912, 3.443362, 3.523949, 3.356742, 3.326824, 
      3.361116, 3.329555, 3.405907, 3.318638, 3.358363, 3.325886, 3.215641, 
      3.249897, 3.193256, 3.093751, 3.142300, 2.962172, 2.988197, 2.974430, 
      2.903498, 2.959826, 2.799614, 2.808341, 2.789996, 2.806079, 2.804205, 
      2.640753, 2.701464, 2.648010, 2.558500, 2.561186, 2.536839, 2.539420, 
      2.531719, 2.542716, 2.474663, 2.460622, 2.473782, 2.416596, 2.428304, 
      2.333293, 2.308599, 2.308596, 2.269926, 2.294564, 2.211207, 2.173211, 
      2.176689, 2.147503, 2.165855, 2.091327, 2.098252, 2.048984, 1.996937, 
      1.999400, 1.975719, 1.976396, 1.971259, 1.977828, 1.963726, 1.970238, 
      1.902792, 1.861247, 1.865153, 1.809646, 1.817039, 1.774486, 1.723989, 
      1.725202, 1.711239, 1.711530, 1.711184, 1.712291, 1.691755, 1.697858, 
      1.661993, 1.604521, 1.605098, 1.577795, 1.578235, 1.576655, 1.581052, 
      1.561246, 1.501499, 1.502135, 1.500709, 1.501678, 1.470566, 1.472271, 
      1.470847, 1.401952, 1.402653, 1.388286, 1.380672, 1.382632, 1.315780, 
      1.310839, 1.311137, 1.305978, 1.306964, 1.286242, 1.287142, 1.217770, 
      1.217769, 1.216284, 1.217196, 1.191343, 1.159046, 1.159105, 1.155702, 
      1.155780, 1.155158, 1.155263, 1.139069, 1.139102, 1.132398, 1.133038, 
      1.087100, 1.077849, 1.078227, 1.023271, 1.023313, 1.018460, 1.018474, 
      1.016401, 1.016485, 1.004151, 1.004352, 0.9529943, 0.9530217, 0.9457213, 
      0.9457576, 0.9411379, 0.9412247, 0.9248197, 0.9114929, 0.9115527, 0.8960604, 
      0.8961528, 0.8525744, 0.8525833, 0.8504073, 0.8504470, 0.8214312, 0.8214452, 
      0.8043641, 0.8044020, 0.7657748, 0.7657828, 0.7586192, 0.7586234, 0.7563543, 
      0.7563552, 0.7531477, 0.7531540, 0.7436672, 0.7436756, 0.7401005, 0.7260009, 
      0.7260144, 0.6911417, 0.6911417, 0.6894789, 0.6894788, 0.6889485, 0.6889507, 
      0.6789922, 0.6789928, 0.6761626, 0.6761654, 0.6585229, 0.6585282, 0.6262228, 
      0.6262228, 0.6259680, 0.6259683, 0.6235617, 0.6235619, 0.6172491, 0.6172500, 
      0.6167751, 0.6000248, 0.6000264, 0.5710482, 0.5710481, 0.5696407, 0.5696407, 
      0.5655632, 0.5655637, 0.5489853, 0.5489857, 0.5286670, 0.5227898, 0.5227897, 
      0.5215338, 0.5215337, 0.5206241, 0.5206240, 0.5199946, 0.5199947, 0.5041903, 
      0.5041903, 0.4801457, 0.4801456, 0.4796316, 0.4796315, 0.4646620, 0.4646619, 
      0.4625845, 0.4625841, 0, 0 };

      auto out = coh(temp,lat,emax,numAtoms,eGrid,tol);
      std::vector<double> finalE  = std::get<0>(out),
                          finalXS = std::get<1>(out),
                          addedE  = std::get<2>(out);

      THEN ( "final energies and xs value must match AND " 
             "each finalE energy value must be in *either* eGrid or addedE" ){
        REQUIRE( ranges::equal(finalE,correct_finalE,equal) );
        REQUIRE( ranges::equal(finalXS,correct_finalXS,equal) );
        checkAddedEnergies( finalE, eGrid, addedE );
      } // THEN
      
    } // WHEN
  } // GIVEN





  GIVEN( "material is beryllium oxide (lat = 3)" ){
    WHEN( "" ){
      double temp = 500.0, emax = 0.045;
      int lat = 3, numAtoms = 1;
      double tol = 9e-2;

      std::vector<double> correct_finalE;
      correct_finalE = { 1.E-5, 1.0625E-5, 1.125E-5, 1.1875E-5, 1.25E-5, 
      1.375E-5, 1.5E-5, 1.625E-5, 1.75E-5, 1.875E-5, 2.E-5, 2.1875E-5, 2.375E-5, 
      2.5625E-5, 2.75E-5, 2.9375E-5, 3.125E-5, 3.3125E-5, 3.5E-5, 3.875E-5, 
      4.25E-5, 4.625E-5, 5.E-5, 5.3125E-5, 5.625E-5, 5.9375E-5, 6.25E-5, 6.875E-5, 
      7.5E-5, 8.125E-5, 8.75E-5, 9.375E-5, 1.E-4, 1.0625E-4, 1.125E-4, 1.1875E-4, 
      1.25E-4, 1.375E-4, 1.5E-4, 1.625E-4, 1.75E-4, 1.875E-4, 2.E-4, 2.1875E-4, 
      2.375E-4, 2.5625E-4, 2.75E-4, 2.9375E-4, 3.125E-4, 3.3125E-4, 3.5E-4, 
      3.875E-4, 4.25E-4, 4.625E-4, 5.E-4, 5.3125E-4, 5.625E-4, 5.9375E-4, 6.25E-4, 
      6.875E-4, 7.5E-4, 8.125E-4, 8.75E-4, 9.375E-4, 1.E-3, 1.061173E-3, 
      1.061175E-3, 1.0625E-3, 1.125E-3, 1.1875E-3, 1.25E-3, 1.375E-3, 1.5E-3, 
      1.625E-3, 1.75E-3, 1.875E-3, 2.E-3, 2.1875E-3, 2.375E-3, 2.5625E-3, 
      2.75E-3, 2.9375E-3, 3.125E-3, 3.3125E-3, 3.5E-3, 3.754367E-3, 3.754369E-3, 
      3.875E-3, 4.244695E-3, 4.244697E-3, 4.25E-3, 4.625E-3, 4.815541E-3, 
      4.815543E-3, 5.E-3, 5.3125E-3, 5.625E-3, 5.9375E-3, 6.25E-3, 6.875E-3, 
      7.5E-3, 7.999063E-3, 7.999065E-3, 8.125E-3, 8.75E-3, 9.375E-3, 9.550565E-3, 
      9.550567E-3, 1.E-2, 1.0625E-2, 1.125E-2, 1.126309E-2, 1.126311E-2, 
      1.1875E-2, 1.232427E-2, 1.232429E-2, 1.25E-2, 1.330492E-2, 1.330494E-2, 
      1.375E-2, 1.5E-2, 1.501746E-2, 1.501748E-2, 1.550779E-2, 1.550781E-2, 
      1.607864E-2, 1.607866E-2, 1.625E-2, 1.697877E-2, 1.697879E-2, 1.75E-2, 
      1.875E-2, 1.926216E-2, 1.926218E-2, 2.E-2, 2.073314E-2, 2.073316E-2, 
      2.081366E-2, 2.081368E-2, 2.1325E-2, 2.265E-2, 2.3975E-2, 2.456803E-2, 
      2.456805E-2, 2.53E-2, 2.628057E-2, 2.628059E-2, 2.652934E-2, 2.652936E-2, 
      2.684375E-2, 2.734174E-2, 2.734176E-2, 2.824188E-2, 2.82419E-2, 2.83875E-2, 
      3.028371E-2, 3.028373E-2, 3.052526E-2, 3.052528E-2, 3.1475E-2, 3.199625E-2, 
      3.199627E-2, 3.37893E-2, 3.378932E-2, 3.45625E-2, 3.485048E-2, 3.48505E-2, 
      3.583113E-2, 3.583115E-2, 3.765E-2, 3.779245E-2, 3.779247E-2, 3.8034E-2, 
      3.803402E-2, 3.820226E-2, 3.820228E-2, 4.07375E-2, 4.154681E-2, 4.154683E-2, 
      4.195662E-2, 4.195664E-2, 4.325935E-2, 4.325937E-2, 4.333987E-2, 4.333989E-2, 
      4.3825E-2, 4.499999E-2, 4.5E-2, 4.500001E-2, 2.E7 };
      std::vector<double> correct_finalXS;
      correct_finalXS = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4.840605, 4.689914, 
      4.281442, 7.003527, 6.994788, 6.427643, 6.173314, 9.404996, 9.058032, 
      8.525207, 8.051584, 7.627817, 7.246426, 6.587660, 6.038688, 5.661933, 
      7.167094, 7.056006, 6.552006, 6.115205, 6.002792, 6.002790, 5.733005, 
      5.395769, 5.096004, 5.090082, 8.478790, 8.041899, 7.748739, 7.748726, 
      7.639804, 7.177612, 10.48224, 10.14296, 9.297709, 9.286899, 9.811629, 
      9.501414, 11.52971, 11.12038, 11.57973, 11.45764, 10.96585, 10.97739, 
      10.65044, 9.940415, 9.676110, 10.02542, 9.655570, 9.314142, 9.326383, 
      9.290312, 9.290303, 9.067545, 8.537104, 8.065293, 7.870611, 9.012758, 
      8.752011, 8.425460, 8.818601, 8.735914, 8.735908, 8.633594, 8.476346, 
      8.835642, 8.554034, 8.582059, 8.538041, 8.003433, 8.779805, 8.710335, 
      9.014037, 8.742049, 8.599633, 8.605169, 8.148536, 8.639017, 8.445758, 
      8.375968, 8.375964, 8.146729, 9.271475, 8.823575, 8.790317, 8.790312, 
      8.734491, 9.131654, 9.091439, 9.157053, 8.587181, 8.419907, 8.838906, 
      8.752576, 8.834123, 8.568092, 8.574202, 8.558277, 8.558273, 8.463539, 
      8.242548, 8.242547, 0, 0};

      auto out = coh(temp,lat,emax,numAtoms,eGrid,tol);
      std::vector<double> finalE  = std::get<0>(out),
                          finalXS = std::get<1>(out),
                          addedE  = std::get<2>(out);

      THEN ( "final energies and xs value must match AND " 
             "each finalE energy value must be in *either* eGrid or addedE" ){
        REQUIRE( ranges::equal(finalE,correct_finalE,equal) );
        REQUIRE( ranges::equal(finalXS,correct_finalXS,equal) );
        checkAddedEnergies( finalE, eGrid, addedE );
      } // THEN
      
    } // WHEN
  } // GIVEN

  GIVEN( "material is beryllium oxide (lat = 2)" ){
    WHEN( "" ){
      double temp = 500.0, emax = 0.045;
      int lat = 3, numAtoms = 1;
      double tol = 0.001;


      std::vector<double> correct_finalE;
      correct_finalE = { 1.0E-5, 1.0625E-5, 1.125E-5, 1.1875E-5, 1.250E-5, 
      1.375E-5, 1.5E-5, 1.625E-5, 1.75E-5, 1.875E-5, 2.0E-5, 2.1875E-5, 2.375E-5, 
      2.5625E-5, 2.750E-5, 2.9375E-5, 3.125E-5, 3.3125E-5, 3.5E-5, 3.875E-5, 
      4.250E-5, 4.625E-5, 5.0E-5, 5.3125E-5, 5.625E-5, 5.9375E-5, 6.250E-5, 
      6.875E-5, 7.5E-5, 8.125E-5, 8.750E-5, 9.375E-5, 1.0E-4, 1.0625E-4, 
      1.125E-4, 1.1875E-4, 1.250E-4, 1.375E-4, 1.5E-4, 1.625E-4, 1.750E-4, 
      1.875E-4, 2.0E-4, 2.1875E-4, 2.375E-4, 2.5625E-4, 2.750E-4, 2.9375E-4, 
      3.125E-4, 3.3125E-4, 3.5E-4, 3.875E-4, 4.250E-4, 4.625E-4, 5.0E-4, 
      5.3125E-4, 5.625E-4, 5.9375E-4, 6.250E-4, 6.875E-4, 7.5E-4, 8.125E-4, 
      8.750E-4, 9.375E-4, 1.0E-3, 1.061173E-3, 1.061175E-3, 1.0625E-3, 1.125E-3, 
      1.1875E-3, 1.250E-3, 1.375E-3, 1.5E-3, 1.625E-3, 1.750E-3, 1.875E-3, 
      2.0E-3, 2.1875E-3, 2.375E-3, 2.5625E-3, 2.750E-3, 2.9375E-3, 3.125E-3, 
      3.3125E-3, 3.5E-3, 3.754367E-3, 3.754369E-3, 3.875E-3, 4.059848E-3, 
      4.244695E-3, 4.244697E-3, 4.250E-3, 4.4375E-3, 4.625E-3, 4.815541E-3, 
      4.815543E-3, 5.0E-3, 5.3125E-3, 5.625E-3, 5.9375E-3, 6.250E-3, 6.5625E-3, 
      6.875E-3, 7.1875E-3, 7.5E-3, 7.749532E-3, 7.999063E-3, 7.999065E-3, 
      8.125E-3, 8.4375E-3, 8.750E-3, 9.0625E-3, 9.375E-3, 9.550565E-3, 
      9.550567E-3, 0.01, 0.010625, 0.01125, 0.01126309, 0.01126311, 0.011875, 
      0.01232427, 0.01232429, 0.0125, 0.01330492, 0.01330494, 0.01375, 0.014375, 
      0.015, 0.01501746, 0.01501748, 0.01550779, 0.01550781, 0.01607864, 
      0.01607866, 0.01625, 0.01697877, 0.01697879, 0.0175, 0.018125, 0.01875, 
      0.01926216, 0.01926218, 0.02, 0.02073314, 0.02073316, 0.02081366, 
      0.02081368, 0.021325, 0.02265, 0.023975, 0.02456803, 0.02456805, 0.0253, 
      0.02628057, 0.02628059, 0.02652934, 0.02652936, 0.02684375, 0.02734174, 
      0.02734176, 0.02824188, 0.0282419, 0.0283875, 0.02933561, 0.03028371, 
      0.03028373, 0.03052526, 0.03052528, 0.031475, 0.03199625, 0.03199627, 
      0.0337893, 0.03378932, 0.0345625, 0.03485048, 0.0348505, 0.03583113, 
      0.03583115, 0.03765, 0.03779245, 0.03779247, 0.038034, 0.03803402, 
      0.03820226, 0.03820228, 0.03946989, 0.0407375, 0.04154681, 0.04154683, 
      0.04195662, 0.04195664, 0.04325935, 0.04325937, 0.04333987, 0.04333989, 
      0.043825, 0.04499999, 0.045, 0.04500001, 2E7 };
      std::vector<double> correct_finalXS;
      correct_finalXS = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4.840605, 4.689914, 
      4.476378, 4.281442, 7.003527, 6.994788, 6.699234, 6.427643, 6.173314, 
      9.404996, 9.058032, 8.525207, 8.051584, 7.627817, 7.246426, 6.901358, 
      6.587660, 6.301240, 6.038688, 5.844245, 5.661933, 7.167094, 7.056006, 
      6.794673, 6.552006, 6.326075, 6.115205, 6.002792, 6.002790, 5.733005, 
      5.395769, 5.096004, 5.090082, 8.478790, 8.041899, 7.748739, 7.748726, 
      7.639804, 7.177612, 10.48224, 10.14296, 9.701957, 9.297709, 9.286899, 
      9.811629, 9.501414, 11.52971, 11.12038, 11.57973, 11.45764, 10.96585, 
      10.97739, 10.65044, 10.28319, 9.940415, 9.676110, 10.02542, 9.655570, 
      9.314142, 9.326383, 9.290312, 9.290303, 9.067545, 8.537104, 8.065293, 
      7.870611, 9.012758, 8.752011, 8.425460, 8.818601, 8.735914, 8.735908, 
      8.633594, 8.476346, 8.835642, 8.554034, 8.582059, 8.538041, 8.262096, 
      8.003433, 8.779805, 8.710335, 9.014037, 8.742049, 8.599633, 8.605169, 
      8.148536, 8.639017, 8.445758, 8.375968, 8.375964, 8.146729, 9.271475, 
      8.823575, 8.790317, 8.790312, 8.734491, 9.131654, 9.091439, 9.157053, 
      8.862966, 8.587181, 8.419907, 8.838906, 8.752576, 8.834123, 8.568092, 
      8.574202, 8.558277, 8.558273, 8.463539, 8.242548, 8.242547, 0, 0 };

      auto out = coh(temp,lat,emax,numAtoms,eGrid,tol);
      std::vector<double> finalE  = std::get<0>(out),
                          finalXS = std::get<1>(out),
                          addedE  = std::get<2>(out);

      THEN ( "final energies and xs value must match AND " 
             "each finalE energy value must be in *either* eGrid or addedE" ){
        REQUIRE( ranges::equal(finalE,correct_finalE,equal) );
        REQUIRE( ranges::equal(finalXS,correct_finalXS,equal) );
        checkAddedEnergies( finalE, eGrid, addedE );
      } // THEN

    } // WHEN
  } // GIVEN




} // TEST CASE
